package cn.JL.test;

import com.JL.engine.GameWorld;
import com.JL.engine.model.Entity;
import com.JL.engine.model.View;
import com.JL.window.GameWindow;

import java.awt.*;

public class TankGame extends GameWindow {
    TankGame(){
        setTitle("坦克大战");
    }
    public static void main(String[] args) {
        TankGame tankGame = new TankGame();
        GameWorld gameWorld = tankGame.getGameWorld();
        Entity entity = new Entity();
        entity.setPosition(100,100);
        entity.setSize(100,100);
        entity.addView(new View() {
            @Override
            public void draw(Graphics g, Entity entity) {
                g.setColor(Color.RED);
                g.fillRect((int)entity.getX(),(int)entity.getY(),(int)entity.getWidth(),(int)entity.getHeight());
            }
        });
        gameWorld.addEntity(entity);

        new Thread(()->{
            for (int i = 0;i < 10;i++) {
                entity.setTranslation(10,0);
                try {
                    Thread.sleep(500);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        }).start();
    }
}